package user

import (
	"github.com/bgmp/config"
	"github.com/bgmp/handler"
	"github.com/bgmp/model"
	"github.com/gin-gonic/gin"
	log "github.com/sirupsen/logrus"
)

func (b Base) GetBg(c *gin.Context, req *GetBgRequest) *GetBgResponse {
	bg := &model.Bg{}
	bg.ID = req.Id
	err := bg.Get(config.DB)
	if err != nil {
		handler.Errorf(c, "获取记录失败")
		log.Error(err)
		return nil
	}
	return &GetBgResponse{
		Bg: model.FormatBgView(bg),
	}
}

type GetBgRequest struct {
	Id uint `json:"id"`
}

type GetBgResponse struct {
	Bg model.BgView `json:"bg"`
}
